package com.gimi.cloud.jimi.client.controller.moreInfo;

import com.alibaba.fastjson.JSON;
import com.gimi.cloud.jimi.client.service.moreInfo.CreditcardEmailService;
import com.gimi.cloud.jimi.common.utils.reqhead.Response;
import com.gimi.cloud.jimi.common.utils.reqhead.Util;
import com.gimi.cloud.jimi.dto.app.moreInfo.FengchaoEmailDTO;
import com.gimi.cloud.jimi.dto.app.moreInfo.FengchaoPositionDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;


/**
 * 蜂巢信用卡相关服务
 */
@RestController
@RequestMapping(value = "/moreInfo")
public class CreditcardEmailController {

	private static final Logger log = LoggerFactory.getLogger(CreditcardEmailController.class);

	private CreditcardEmailService creditcardEmailService;
    @Autowired
	public CreditcardEmailController(CreditcardEmailService creditcardEmailService) {
		this.creditcardEmailService = creditcardEmailService;
	}

	/**
	 * 获取支持银行列表
	 * @param fengchaoEmailDTO
	 * @param response
	 */
	@RequestMapping(value = "/getFengchaoEmailList")
	public void getFengchaoEmailList(@RequestBody FengchaoEmailDTO fengchaoEmailDTO , HttpServletResponse response){
		log.info("获取蜂巢信用卡支持的邮箱列表,入参"+fengchaoEmailDTO);
		Response responsedata = creditcardEmailService.getFengchaoEmailList(fengchaoEmailDTO);
		Util.sendResponse(JSON.toJSONString(responsedata), response);
	}

	/**
	 * 获取支持银行列表
	 * @param fengchaoPositionDTO
	 * @param response
	 */
	@RequestMapping(value = "/getFengchaoPositionList")
	public void getFengchaoPositionList(@RequestBody FengchaoPositionDTO fengchaoPositionDTO, HttpServletResponse response){
		log.info("蜂巢邮箱支持的Position列表,入参"+fengchaoPositionDTO);
		Response responsedata = creditcardEmailService.getFengchaoPositionList(fengchaoPositionDTO);
		Util.sendResponse(JSON.toJSONString(responsedata), response);
	}

	/**
	 * 蜂巢邮箱登录
	 * @param fengchaoEmailDTO
	 * @param response
	 */
	@RequestMapping(value = "/getFengchaoEmailLogin")
	public void getFengchaoEmailLogin(@RequestBody FengchaoEmailDTO fengchaoEmailDTO, HttpServletResponse response){
		log.info("蜂巢邮箱登录,入参"+fengchaoEmailDTO);
		Response responsedata = creditcardEmailService.getFengchaoEmailLogin(fengchaoEmailDTO);
		Util.sendResponse(JSON.toJSONString(responsedata), response);
	}

	/**
	 * 蜂巢邮箱状态查询接口
	 * @param fengchaoEmailDTO
	 * @param response
	 */
	@RequestMapping(value = "/getFengchaoEmailStatus")
	public void getFengchaoEmailStatus(@RequestBody FengchaoEmailDTO fengchaoEmailDTO, HttpServletResponse response){
		log.info("蜂巢邮箱状态查询接口,入参"+fengchaoEmailDTO);
		Response responsedata = creditcardEmailService.getFengchaoEmailStatus(fengchaoEmailDTO.getAppemailkey(),fengchaoEmailDTO.getUserId());
		Util.sendResponse(JSON.toJSONString(responsedata), response);
	}

	/**
	 * 蜂巢邮箱独立密码提交接口
	 * @param fengchaoEmailDTO
	 * @param response
	 */
	@RequestMapping(value = "/subFengchaoEmailIndependentPassWord")
	public void subFengchaoEmailIndependentPassWord(@RequestBody FengchaoEmailDTO fengchaoEmailDTO, HttpServletResponse response){
		log.info("蜂巢邮箱独立密码提交接口,入参"+fengchaoEmailDTO);
		Response responsedata = creditcardEmailService.subFengchaoEmailIndependentPassWord(fengchaoEmailDTO);
		Util.sendResponse(JSON.toJSONString(responsedata), response);
	}

	/**
	 * 蜂巢邮箱登验证码提交接口
	 * @param fengchaoEmailDTO
	 * @param response
	 */
	@RequestMapping(value = "/subFengchaoEmailValidCode")
	public void subFengchaoEmailValidCode(@RequestBody FengchaoEmailDTO fengchaoEmailDTO, HttpServletResponse response){
		log.info("蜂巢邮箱登验证码提交接口,入参"+fengchaoEmailDTO);
		Response responsedata = creditcardEmailService.subFengchaoEmailValidCode(fengchaoEmailDTO);
		Util.sendResponse(JSON.toJSONString(responsedata), response);
	}
}
